package com.pgy.backend.controller;

import com.pgy.backend.entity.User;
import com.pgy.backend.service.UserService;
import com.pgy.backend.vo.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/admin")
@Api(tags = "登录相关接口")
public class UserController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    @ApiOperation(value = "登录接口")
    public ResultData login(@RequestBody User user) {

        return userService.login(user);
        // return ResultData.error(ReturnCode.CODE_400.getCode(), "登录失败, Id不能为空");
    }
}
